﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DAL
{
   public static class DBHelper
    {
        static string  connString = ConfigurationManager.ConnectionStrings["conn"].ToString();
        public static DataTable GetTable(string sql) {
            SqlConnection conn = new SqlConnection(connString);

            conn.Open();
            SqlCommand command = new SqlCommand(sql,conn);
            SqlDataAdapter sda = new SqlDataAdapter(command);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            //conn.Close();
            return ds.Tables[0];
        }

        public static int ExecutNonQuery(string sql) 
        {
            SqlConnection conn = new SqlConnection(connString);
            conn.Open();
            SqlCommand sqlcmd = new SqlCommand(sql,conn);
            int i = sqlcmd.ExecuteNonQuery();
            conn.Close();
            return i;

        }
    }
}
